//
//  ProductDetailsViewController.m
//  mhome
//
//  Created by 刘春雷 on 2018/11/26.
//  Copyright © 2018年 刘春雷. All rights reserved.
//

#import "ProductDetailsViewController.h"
#import <UIImageView+WebCache.h>

@interface ProductDetailsViewController ()<UIScrollViewDelegate>
@property(nonatomic,copy)NSArray *topImageArray;//顶部图片array
@property(nonatomic,copy)NSArray *describeArray;//设计理念array
@property(nonatomic,copy)NSArray *tagArray;//标签array
@property (nonatomic,strong) UIScrollView *scrollView;//滚动视图
@end

@implementation ProductDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.productStr;
    self.topImageArray = [NSArray arrayWithObjects:@"商品-艾美_02",@"商品-凯撒_02",@"商品-SOHO_02", nil];
    self.describeArray = [NSArray arrayWithObjects:@"[设计理念]新生命诞生的喜悦，朋友闲聚的一杯新鲜咖啡，阳光下慵懒的宠物。我们眼里的生活，温馨，舒适，安心，充实。艾美在家，拥有人生美好体验。",@"[设计理念]作家再画画，诗人在摄影，玩滑板的想去开热气球。我们眼里的生活，自由、奔放、有趣、个性。SOHO在家，开启人生的无限可能。",@"[设计理念]全家人团聚的温馨晚餐，清晨再瑜伽肿清醒的身影，书房里安静的思考。我们眼里的生活，典雅浪漫，低调奢华。凯撒在家，拥有人生品质体验。", nil];
    self.tagArray = [NSArray arrayWithObjects:@"餐厅",@"主卧",@"次卧",@"儿童房",@"客厅",@"书房",@"阳台",@"卫生间", nil];
    [self setUI];
}
- (void)setUI {
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRects(0, 0, 375, 667)];
    self.scrollView.backgroundColor = [UIColor colorWithRed:232.0/255.0 green:234.0/255.0 blue:235.0/255.0 alpha:1.0];
    self.scrollView.pagingEnabled = NO;//是否整页滚动
    self.scrollView.bounces = NO;//是否反弹
    self.scrollView.contentSize = CGSizeMake(kSCREEN_WIDTH,1910*kHeightScale);
    self.scrollView.showsHorizontalScrollIndicator = NO;//是否显示水平滚动条
    self.scrollView.showsVerticalScrollIndicator = NO;//是否显示垂直滚动条
    self.scrollView.delegate = self;
    [self.view addSubview:self.scrollView];
    
    
    UIImageView *topBackColor = [[UIImageView alloc]init];
    topBackColor.backgroundColor = [UIColor colorWithRed:61.0/255.0 green:61.0/255.0 blue:61.0/255.0 alpha:1.0];
    topBackColor.frame = CGRects(0, 0, 375, 40);
    [self.scrollView addSubview:topBackColor];
    UIImageView *topImage = [[UIImageView alloc]init];
    topImage.frame = CGRects(0, 40, 375, 60);
    [self.scrollView addSubview:topImage];
    UILabel *describeLabel = [[UILabel alloc] initWithFrame:CGRects(10, 100, 355, 80)];
    describeLabel.backgroundColor = [UIColor clearColor];
    describeLabel.font = [UIFont systemFontOfSize:12.0];
    describeLabel.textColor = [UIColor blackColor];
    describeLabel.numberOfLines = 0;
    [self.scrollView addSubview:describeLabel];
    if([self.productStr isEqualToString:@"艾美"]){
       [topImage setImage:[UIImage imageNamed:_topImageArray[0]]];
        describeLabel.text = _describeArray[0];
    }else if([self.productStr isEqualToString:@"凯撒"]) {
       [topImage setImage:[UIImage imageNamed:_topImageArray[1]]];
        describeLabel.text = _describeArray[1];
    }else{
       [topImage setImage:[UIImage imageNamed:_topImageArray[2]]];
        describeLabel.text = _describeArray[2];
    }
    
    for (int j = 0; j < 8; j ++) {
        UIImageView *setImage = [[UIImageView alloc] initWithFrame:CGRects(10, (175+210*j), 355, 160)];
        //网络上获取图片
        [setImage sd_setImageWithURL:[NSURL URLWithString:self.imageArray[j]]];
        [self.scrollView addSubview:setImage];
        
        UILabel *taglabel = [[UILabel alloc] initWithFrame:CGRects(10, (335+210*j), 355, 40)];
        taglabel.text = _tagArray[j];
        taglabel.textColor = [UIColor blackColor];
        taglabel.textAlignment = NSTextAlignmentCenter;
        taglabel.backgroundColor = [UIColor whiteColor];
        taglabel.textAlignment = NSTextAlignmentCenter;//设置字体居中
        taglabel.font = [UIFont systemFontOfSize:16.0];//设置字体大小
        [self.scrollView addSubview:taglabel];
    }
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
